<?php
gatekeeper ();

$project = $vars ['entity'];
$user = elgg_get_logged_in_user_entity ();
$members_label = elgg_echo ( 'submana:project:members' );

$name_label = elgg_echo ( 'submana:addprojects:name' );

$descp_label = elgg_echo ( 'Mô tả đề tài' );

$name_input = elgg_view ( 'input/text', array (
		'name' => 'name',
		'class' => "required" 
) );

$descp_input = elgg_view ( 'input/longtext', array (
		'name' => 'description',
		'class' => "required" 
) );

$content .= "<div>";
$content .= elgg_view ( 'input/text', array (
		'name' => 'member1',
		'id' => 'project_member1',
		'value' => $user->username,
		'readonly' => true 
) );
$content .= elgg_view ( 'input/text', array (
		'name' => 'member2',
		'id' => 'project_member2' 
) );
$content .= elgg_view ( 'input/text', array (
		'name' => 'member3',
		'id' => 'project_member3' 
) );

$content .= "</div>";
$member_avalable = 3;

// ---------------- input/hidden ---------------------
$group_project = elgg_view ( 'input/hidden', array (
		'name' => 'group_project',
		'value' => $vars ['group_project'] 
) );
$semester = elgg_view ( 'input/hidden', array (
		'name' => 'semester',
		'value' => $vars ['semester'] 
) );
$academic_year = elgg_view ( 'input/hidden', array (
		'name' => 'academic_year',
		'value' => $vars ['academic_year'] 
) );

$projectlist_guid = elgg_view ( 'input/hidden', array (
		'name' => 'projectlist_guid',
		'value' => $vars ['projectlist_guid'] 
) );

$group_guid = elgg_view ( 'input/hidden', array (
		'name' => 'group_guid',
		'id' => "group_guid",
		'value' => $vars ['group_guid'] 
) );
$members = elgg_view ( 'input/hidden', array (
		'name' => 'total_member',
		'id' => "total_member",
		'value' => $member_avalable 
) );

$next_button = elgg_view ( 'input/button', array (
		'name' => 'action',
		'value' => elgg_echo ( 'submana:projects:addmember' ),
		'class' => 'elgg-button-action',
		'onclick' => "addmember()" 
) );

// ------------------- buttons -----------------------
$save_button = elgg_view ( 'input/submit', array (
		'value' => elgg_echo ( 'submana:addprojects:save' ) 
) );
$reset_button = elgg_view ( 'input/reset', array (
		'value' => elgg_echo ( 'submana:addprojects:reset' ) 
) );
echo <<<___HTML
<div>
	<label>$name_label</label>
	$name_input
</div>
<div>
	<label>$descp_label</label>
	$descp_input
</div>
<div>
	<label for="members">$members_label</label>
	<div style="width: 50%; margin: 20px;">
		<div id="project_memeber">
			$content
		</div>
		<div>
			$next_button
		</div>
	</div>
</div>
<div>
	$members
	$group_guid
	$group_project
	$semester
	$academic_year
	$projectlist_guid
	$save_button
	$reset_button
</div>
<div>
	$url_similar_project
	$similar_project_div
</div>
___HTML;

?>


<script type="text/javascript">

var member = <?php echo $member_avalable;?>;
function addmember(){
	member++;
	var strHTML = '<div>'+
				  '<input type="text" value="" name="member'+member+'" '+
				  'id="project_member'+member+'" class="elgg-input-text">'+
				  '</div>';
	$('#project_memeber').append(strHTML);
	$('#total_member').val(member);
}

function toggle(project_group){
	$("#"+project_group).toggle();
}
</script>

